package cn.xm.lingshi.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import cn.xm.lingshi.pojo.Dz_ShengFen;
import cn.xm.lingshi.service.Dz_ShengFenSrevice;
import cn.xm.lingshi.service.impl.Dz_ShengFenSreviceImpl;
/**
 * 城市控制器Servlet
 * @author 魏魁
 *
 */
public class CityServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void destroy() {
		super.destroy(); 
	}
	private  void suoYou_ShengFei(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException{
		PrintWriter out = response.getWriter();
		Dz_ShengFenSrevice dsfs=new Dz_ShengFenSreviceImpl();

		List<Dz_ShengFen> list=dsfs.list();
		out.print(JSON.toJSONString(list));
		System.out.println(list.get(0).getS_id()+"  "+list.get(0).getS_name());
		
	}
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		String shengFen=request.getParameter("sf");
		if (shengFen!=null && !"".equals(shengFen)) {
			this.suoYou_ShengFei(request, response);
		} else {

		}
		out.flush();
		out.close();
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doGet(request, response);
	}

	/**
	 * Initialization of the servlet. <br>
	 * 
	 * @throws ServletException
	 *             if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
